package com.xiguaji.tiktok.v1.ins.rank.repository;

import com.xiguaji.tiktok.v1.ins.rank.model.InsRkProductWeek;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface InsRkProductWeekRepository extends CrudRepository<InsRkProductWeek,Long>,InsRkProductWeekExtRepository {


    @Query("SELECT distinct IFNULL(max(create_time),0) FROM `ins_rk_product_week` where category_name = :category")
    long getMaxCreateTime(String category);

    @Query("SELECT distinct IFNULL(max(datecode),0) FROM `ins_rk_product_week` where category_name = :category")
    int getMxDateCode(String category);

    @Query("select DISTINCT(datecode) from ins_rk_product_week where category_name=:category and datecode >=:startDate ORDER BY datecode  DESC limit 0,:size")
    List<Integer> findDateCode(String category, int startDate, int size);
}
